import {genTemplate, getVue3SetUpJS} from "@/utils/generator/template.ts";
import formatCode, {prettierCode} from "@/utils/generator/formatCode.ts";


/**
 * 获取 vue3 SFC代码
 */
export const genElementVue3SFC = function (formConfig: any, formDesigner: any) {
    // const html = beautifier.html(genTemplate(formConfig, widgetList, vue3Flag), beautifierOpts.html)
    // const js = beautifier.js(!!vue3Flag ? genVue3JS(formConfig, widgetList) : genVue2JS(formConfig, widgetList), beautifierOpts.js)

    const html = genTemplate(formConfig, formDesigner)
    const js = getVue3SetUpJS(formConfig, formDesigner)

    const result = `
<template>
${html}
</template>

<script setup lang="ts">
${js}
</script>

<style scope>


</style>

`
    return formatCode(result)

    // const c = '<template><div id="app"><router-view/></div></template>\n' +
    //     '<script>export default {name: \'MagicTemplateWebApp\',data() {return {};},mounted() {},methods: {},};\n' +
    //     '</script>\n' +
    //     '<style lang="scss"></style>\n'
    //
    // return prettierCode(c)
}


/**
 * 获取SFC代码
 * @param formConfig
 * @param widgetList
 * @param beautifier
 * @param vue3Flag
 */
export const genElementSFC = function (formConfig, widgetList, beautifier, vue3Flag = false) {
    // const html = beautifier.html(genTemplate(formConfig, widgetList, vue3Flag), beautifierOpts.html)
    // const js = beautifier.js(!!vue3Flag ? genVue3JS(formConfig, widgetList) : genVue2JS(formConfig, widgetList), beautifierOpts.js)

    const html = ''
    const js = ''

    return `
<template>
${html}
</template>

<script>
${js}
</script>`
}
